package http;

import java.io.IOException;
import java.io.InputStream;

/**
 * @Author: admin
 * @Description:
 * @Date: 2019/3/19 10:27
 */

public class HttpRequest {
    private String url;
    private String method;

    public HttpRequest(InputStream inputStream) throws IOException {
        String httpRequest = "";
        byte[] httpRequestBytes = new byte[1024];
        int length = 0;
        if ((length = inputStream.read(httpRequestBytes)) > 0) {
            httpRequest = new String(httpRequestBytes, 0, length);
            System.out.println(httpRequest);
            String httpHeader = httpRequest.split("\n")[0];
            url = httpHeader.split("\\s")[1];
            method = httpHeader.split("\\s")[0];
        }
    }

    public String getMethod() {
        return method;
    }

    public String getUrl() {
        return url;
    }
}
